import cgi
import datetime
import urllib
import webapp2

import jinja2
import os

dir = os.path.dirname(__file__)
filename = os.path.join(dir, '../view')
jinja_environment = jinja2.Environment(loader=jinja2.FileSystemLoader(filename))

from google.appengine.ext import db

from model.Person import Person

class List1(webapp2.RequestHandler):
    
    def get(self):    
        # obtengo toda la gente que esta en el match
        people_query = Person.all()

        people = people_query.fetch(8)

        # mandar la gente por parametro de la pagina
        template_values = {
                'people': people,
        }

        template = jinja_environment.get_template('list1.html')
        self.response.out.write(template.render(template_values))

    def post(self):
        fb_uid = int(self.request.get('fb_uid'))

        p1 = Person(fb_uid=fb_uid, gender='male', searching='female')
        p1.put()

        self.redirect('/list')
